package com.banciyuan.wallpaper.config.glide;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.module.GlideModule;

/**
 * Created by squall on 2016/7/6.
 */
public class GlideConfig implements GlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {

        Runtime info = Runtime.getRuntime();
        long memory = info.maxMemory();

        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "bcyWall_cache", 360 * 1024 * 1024));
        builder.setDecodeFormat(DecodeFormat.DEFAULT);
        builder.setMemoryCache(new LruResourceCache((int) (memory / 20)));
        builder.setBitmapPool(new LruBitmapPool((int) (memory / 20)));
        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    }

    @Override
    public void registerComponents(Context context, Glide glide) {

    }
}
